Splunk MINT SDK for Android (Legacy)

Splunk MINT SDK for Android Developer Guide

Splunk MINT is no longer available for purchase as of January 29, 2021. Customers who have already been paying to ingest and process MINT data in Splunk Enterprise will continue to receive support until December 31, 2021, which is End of Life for all MINT products: App, Web Service (Management Console), SDK and Add-On.

Report the last error and total crashes

You can find out the last known error a user encountered as the app crashed, and find out the total number of times the app crashed.

  • To find out the hash of the last error, use the getLastCrashID() method:
  • String lastErrorID = Mint.getLastCrashID();
    

    Note The error hash is only displayed in the Splunk MINT App, where you can create a search to find this value. For more about searching MINT data, see Use the Splunk MINT App in the Splunk MINT App User Guide.

  • To find out how many times your app crashed, use the getTotalCrashesNum() method:
  • int totalCrashes = Mint.getTotalCrashesNum();
    
  • To reset the crashes counter, use the clearTotalCrashesNum() method:
  • Mint.clearTotalCrashesNum();
    

    Note These methods are blocking, so use them in an AsyncTask class or a thread.


Example code

public MyActivity extends Activity {
    private final String APIKEY = "TESTAPIKEY";
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Mint.initAndStartSession(this.getApplication(), APIKEY);
        new CheckLastError().execute();
    }
    private class CheckLastError extends AsyncTask<Void, Void, String> {
        @Override
        protected void onPreExecute() {
            super.onPreExecute();
        }
        @Override
        protected String doInBackground(Void... params) {
            int totalCrashes = Mint.getTotalCrashesNum();
            if (totalCrashes > 9) {
                // Get last error hash
                String lastErrorID = Mint.getLastCrashID();
                // Clear the crash counter
                Mint.clearTotalCrashesNum();
                // Return the last error ID
                return lastErrorID;
            }
            return null;
        }
        @Override
        protected void onPostExecute(String lastErrorID) {
            super.onPostExecute(lastErrorID);
            // If there are 10 crashes or more and we have a last error ID
            if (lastErrorID != null) {
                // Create error URL
                String errorUrl =
                    "https://mint.splunk.com/dashboard/project/"
                    + APIKEY + "/errors/" + lastErrorID;
                // Create the URL from your server to send a push notification
                // or email to the user
                String myServerUrl =
                "http://www.myserver.com/notifyUser=" + getUserID();
            }
        }
    }
}
Last modified on 28 January, 2019
Use the crash callback   Disable network monitoring

This documentation applies to the following versions of Splunk MINT SDK for Android (Legacy): 5.2.x


Was this topic useful?







You must be logged into splunk.com in order to post comments. Log in now.

Please try to keep this discussion focused on the content covered in this documentation topic. If you have a more general question about Splunk functionality or are experiencing a difficulty with Splunk, consider posting a question to Splunkbase Answers.

0 out of 1000 Characters